<template>
  <div>
      <div v-if="!isbis" class="header" @mouseleave="headmouseleave" @mouseover="headmouseover">

          <!-- 折叠按钮 -->
          <div @click="collapseChage" class="collapse-btn">
              <i :class="collapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'" style="font-size: 36px;"></i>
          </div>
          <div style="position: absolute;left:40px;">
              <div class="logo" :title="WebVer">
                  <el-dropdown @command="handleSwitchModel" class="swtichmodel" trigger="click" @visible-change="drop1change">
                      <span class="el-dropdown-link">
                          {{ currentModName }}
                      </span>
                      <el-dropdown-menu slot="dropdown" :visibleArrow="false" class="logodropdown" :forceleft="true" :forceleftval="0" :forcewidth="true" :forcewidthval="140">
                          <el-dropdown-item :command="emitem.code" :key="index" v-for="(emitem, index) in bigmodels">{{
                              emitem.name }}</el-dropdown-item>
                      </el-dropdown-menu>
                  </el-dropdown>
              </div>
              <div style="float:left;">
                  <el-menu @select="handleSelect" class="el-menu-demo" mode="horizontal">
                      <template v-for="item in items">
                          <template v-if="item.subs">
                              <el-submenu :index="item.index" :key="item.index" @click="MenuClick(subItem)">
                                  <template slot="title">
                                      <!-- <i :class="item.icon" :style="'color:'+item.iconcolor+';'"></i> -->
                                      <span slot="title">{{ item.title }}</span>
                                  </template>
                                  <template v-for="subItem in item.subs">
                                      <el-submenu :index="subItem.index" :key="subItem.index" v-if="subItem.subs" @click="MenuClick(subitem)">
                                          <template slot="title">{{ subItem.title }}</template>
                                          <el-menu-item :index="threeItem.index" :key="i" v-for="(threeItem, i) in subItem.subs" @click="MenuClick(threeItem)">{{
                                                  threeItem.title }}</el-menu-item>
                                      </el-submenu>
                                      <el-menu-item :index="subItem.index" :key="subItem.index" class="rmtopmenuitem" :class="subItem.headline == 1 ? 'rmtopline' : ''" style="color:#333333;" v-else @click="MenuClick(subItem)">{{ subItem.title }}</el-menu-item>
                                  </template>
                              </el-submenu>
                          </template>
                          <template v-else>
                              <el-menu-item :index="item.index" :key="item.index">
                                  <!-- <i :class="item.icon"></i> -->
                                  <span slot="title" @click="MenuClick(item)">{{ item.title }}</span>
                              </el-menu-item>
                          </template>
                      </template>
                  </el-menu>
              </div>
              <div style="float:left;margin-left:60px;line-height: 35px !important;" v-if="areaflag">{{ selhisna }}</div>
          </div>

          <div class="header-right">
              <div class="header-user-con">
                  <div class="btn-homepage">
                      <el-tooltip placement="top">
                          <div slot="content">放大比例
                              <el-input-number v-model="sizeNum" :precision="1" :step="0.1" @change="handleSizeChange" :min="1.0" :max="5.0" size="mini" label=""></el-input-number>
                          </div>
                          <i class="el-icon-zoom-in"></i>
                      </el-tooltip>
                  </div>
                  <!-- 回到首页 -->
                  <div class="btn-homepage">
                      <el-tooltip content="首页" effect="dark" placement="bottom">
                          <router-link to="/">
                              <i class="el-icon-s-home"></i>
                          </router-link>
                      </el-tooltip>
                  </div>
                  <!-- 全屏显示 -->
                  <div @click="handleFullScreen" class="btn-fullscreen">
                      <el-tooltip :content="fullscreen == 2 ? `取消全屏` : fullscreen == 1 ? `全屏` : `隐藏地址栏`" effect="dark" placement="bottom">
                          <i class="el-icon-rank"></i>
                      </el-tooltip>
                  </div>
                  <div @click="reload" class="btn-homepage">
                      <el-tooltip content="刷新" effect="dark" placement="bottom">
                          <i class="el-icon-refresh"></i>
                      </el-tooltip>
                  </div>
                  <div @click="toggleTopmenu" class="btn-homepage">
                      <el-tooltip :content="topmenuCollapse ? '显示菜单' : '隐藏菜单'" effect="dark" placement="bottom">
                          <i :class="topmenuCollapse ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"></i>
                      </el-tooltip>
                  </div>
                  <!-- 消息中心 -->
                  <div class="btn-bell">
                      <el-tooltip :content="message ? `有${message}条提醒消息` : `消息中心`" effect="dark" placement="bottom">
                          <div @click="openalertcenter()">
                              <i :class="{ 'el-icon-bell': true, 'shake': hasUnreadMessages }"></i>
                          </div>
                      </el-tooltip>
                      <span class="btn-bell-badge" v-if="message"></span>
                  </div>
                  <!-- 用户名下拉菜单 -->
                  <el-dropdown @command="handleCommand" class="user-name" trigger="click" @visible-change="drop2change">
                      <span class="el-dropdown-link">
                          {{ username }}
                          <i class="el-icon-caret-bottom"></i>
                      </span>
                      <el-dropdown-menu slot="dropdown">
                          <el-dropdown-item command="restartdec">重启接口</el-dropdown-item>
                          <router-link to="MNG116" v-if="adminpm">
                              <el-dropdown-item v-if="adminpm">医院管理</el-dropdown-item>
                          </router-link>
                          <el-dropdown-item command="showlog">查看日志</el-dropdown-item>
                          <el-dropdown-item command="upgradeweb" v-if="adminpm">升级程序</el-dropdown-item>
                          <el-dropdown-item command="clearcache">清除缓存</el-dropdown-item>
                          <!-- <el-dropdown-item command="switchmodel">切换模块</el-dropdown-item> -->
                          <el-dropdown-item command="isnullpwd">修改密码</el-dropdown-item>
                          <el-dropdown-item command="upgradeLog">更新日志</el-dropdown-item>
                          <el-dropdown-item command="sendmsg">发送消息</el-dropdown-item>
                          <el-dropdown-item command="loginout">退出登录</el-dropdown-item>
                          <el-dropdown-item command="switchlanguage">{{ $t('i18n.btn') }}</el-dropdown-item>
                          <el-dropdown-item command="calc">计算器</el-dropdown-item>
                          <el-dropdown-item command="notepad">记事本</el-dropdown-item>
                          <el-dropdown-item command="about">关于……</el-dropdown-item>
                      </el-dropdown-menu>
                  </el-dropdown>
                  <div v-if="webbrowser" @click="setwindowmin" class="tool-btn">
                      <el-tooltip content="最小化" effect="dark" placement="bottom">
                          <i class="el-icon-minus"></i>
                      </el-tooltip>
                  </div>
                  <div @click="closewindow" v-if="webbrowser" class="btn-close">
                      <el-tooltip content="关闭" effect="dark" placement="bottom">
                          <i class="el-icon-close"></i>
                      </el-tooltip>
                  </div>
              </div>
          </div>
      </div>
      <div v-if="isbis" class="header" @mouseleave="headmouseleave" @mouseover="headmouseover">
          <!-- 折叠按钮 -->
          <div @click="collapseChage" class="collapse-btn" style="padding-left:16px">
              <i :class="collapse ? 'el-icon-d-arrow-right' : 'el-icon-d-arrow-left'" style="font-size: 20px;line-height:35px"></i>
          </div>
          <div style="position: absolute;left:40px;">
              <div class="logo" :title="WebVer">
                  <el-dropdown @command="handleSwitchModel" class="swtichmodel" trigger="click" @visible-change="drop1change">
                      <span class="el-dropdown-link">
                          {{ currentModName }}
                      </span>
                      <el-dropdown-menu slot="dropdown" :visibleArrow="false" class="logodropdown" :forceleft="true" :forceleftval="0" :forcewidth="true" :forcewidthval="140">
                          <el-dropdown-item :command="emitem.code" :key="index" v-for="(emitem, index) in bigmodels">{{
                              emitem.name }}</el-dropdown-item>
                      </el-dropdown-menu>
                  </el-dropdown>
              </div>
              <div class="bismenu" style="float:left;">
                  <el-menu @select="handleSelect" class="el-menu-demo" mode="horizontal">
                      <template v-for="item in items">
                          <template v-if="item.subs">
                              <el-submenu :index="item.index" :key="item.index" @click="MenuClick(subItem)">
                                  <template slot="title">
                                      <!-- <i :class="item.icon" :style="'color:'+item.iconcolor+';'"></i> -->
                                      <span slot="title">{{ item.title }}</span>
                                  </template>
                                  <template v-for="subItem in item.subs">
                                      <el-submenu :index="subItem.index" :key="subItem.index" v-if="subItem.subs" @click="MenuClick(subitem)">
                                          <template slot="title">{{ subItem.title }}</template>
                                          <el-menu-item :index="threeItem.index" :key="i" v-for="(threeItem, i) in subItem.subs" @click="MenuClick(threeItem)">{{
                                                  threeItem.title }}</el-menu-item>
                                      </el-submenu>
                                      <el-menu-item :index="subItem.index" :key="subItem.index" class="rmbistopmenuitem" :class="subItem.headline == 1 ? 'rmbistopline' : ''" style="color:#333333;" v-else @click="MenuClick(subItem)">{{ subItem.title }}</el-menu-item>
                                  </template>
                              </el-submenu>
                          </template>
                          <template v-else>
                              <el-menu-item :index="item.index" :key="item.index">
                                  <!-- <i :class="item.icon"></i> -->
                                  <span slot="title" @click="MenuClick(item)">{{ item.title }}</span>
                              </el-menu-item>
                          </template>
                      </template>
                  </el-menu>
              </div>
          </div>
          <div class="header-right">
              <div class="header-user-con">
                  <div>
                      <el-input prefix-icon="el-icon-search" ref="searchBox" :placeholder="searchplace" v-model="searchstr" @keyup.enter.native="searchbis()" class="bissearch"></el-input>
                  </div>
                  <div class="btn-homepage">
                      <el-tooltip placement="top">
                          <div slot="content">放大比例
                              <el-input-number v-model="sizeNum" :precision="1" :step="0.1" @change="handleSizeChange" :min="1.0" :max="5.0" size="mini" label=""></el-input-number>
                          </div>
                          <i class="el-icon-zoom-in"></i>
                      </el-tooltip>
                  </div>
                  <!-- 回到首页 -->
                  <!-- <div class="btn-homepage">
                      <el-tooltip content="首页" effect="dark" placement="bottom">
                          <router-link to="/">
                              <i class="el-icon-s-home"></i>
                          </router-link>
                      </el-tooltip>
                  </div> -->
                  <!-- 全屏显示 -->
                  <div @click="handleFullScreen" class="btn-fullscreen">
                      <el-tooltip :content="fullscreen == 2 ? `取消全屏` : fullscreen == 1 ? `全屏` : `隐藏地址栏`" effect="dark" placement="bottom">
                          <i class="el-icon-rank"></i>
                      </el-tooltip>
                  </div>
                  <div @click="reload" class="btn-homepage">
                      <el-tooltip content="刷新" effect="dark" placement="bottom">
                          <i class="el-icon-refresh"></i>
                      </el-tooltip>
                  </div>
                  <!-- <div @click="toggleTopmenu" class="btn-homepage">
                      <el-tooltip :content="topmenuCollapse?'显示菜单':'隐藏菜单'" effect="dark" placement="bottom">
                          <i :class="topmenuCollapse?'el-icon-arrow-down':'el-icon-arrow-up'"></i>
                      </el-tooltip>
                  </div> -->
                  <!-- 消息中心 -->
                  <div class="btn-bell">
                      <el-tooltip :content="message ? `有${message}条提醒消息` : `消息中心`" effect="dark" placement="bottom">
                          <div @click="openalertcenter()">
                              <i :class="{ 'el-icon-bell': true, 'shake': hasUnreadMessages }"></i>
                          </div>
                      </el-tooltip>
                      <span class="btn-bell-badge" v-if="message"></span>
                  </div>

                  <!-- 用户名下拉菜单 -->
                  <el-dropdown @command="handleCommand" trigger="click" @visible-change="drop2change" style="margin-left:10px">
                      <span class="el-dropdown-link">
                          {{ username }}
                          <i class="el-icon-caret-bottom"></i>
                      </span>
                      <el-dropdown-menu slot="dropdown">
                          <el-dropdown-item command="restartdec">重启接口</el-dropdown-item>
                          <router-link to="MNG116" v-if="adminpm">
                              <el-dropdown-item v-if="adminpm">医院管理</el-dropdown-item>
                          </router-link>
                          <el-dropdown-item command="showlog">查看日志</el-dropdown-item>
                          <el-dropdown-item command="upgradeweb" v-if="adminpm">升级程序</el-dropdown-item>
                          <el-dropdown-item command="clearcache">清除缓存</el-dropdown-item>
                          <!-- <el-dropdown-item command="switchmodel">切换模块</el-dropdown-item> -->
                          <el-dropdown-item command="isnullpwd">修改密码</el-dropdown-item>
                          <el-dropdown-item command="upgradeLog">更新日志</el-dropdown-item>
                          <el-dropdown-item command="loginout">退出登录</el-dropdown-item>
                          <el-dropdown-item command="switchlanguage">{{ $t('i18n.btn') }}</el-dropdown-item>
                          <el-dropdown-item command="about">关于……</el-dropdown-item>
                      </el-dropdown-menu>
                  </el-dropdown>
                  <!-- <div v-if="webbrowser" @click="setwindowmin" class="tool-btn">
                      <el-tooltip content="最小化" effect="dark" placement="bottom">
                          <i class="el-icon-minus"></i>
                      </el-tooltip>
                  </div>
                  <div @click="closewindow" v-if="webbrowser" class="btn-close">
                      <el-tooltip content="关闭" effect="dark" placement="bottom">
                          <i class="el-icon-close"></i>
                      </el-tooltip>
                  </div> -->
              </div>
          </div>
      </div>
      <el-dialog :close-on-click-modal="false" :visible.sync="dialogTableVisible" title="请选择模块" class="switchmodeldialog">
          <el-menu @select="handlBMSelect">
              <el-menu-item :index="emitem.code" :key="index" :class="emitem.code == currentMod ? 'modeactive' : ''" v-for="(emitem, index) in bigmodels">{{ emitem.name }}</el-menu-item>
          </el-menu>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" :visible.sync="dialogUpgradeVisible" title="升级程序" class="logmodeldialog" :destroy-on-close="true">
          <el-container>
              <el-header height="30px">
                  <el-row :gutter="20">
                      <el-col :span="6">
                          <el-upload class="upload-demo" :action="uploadurl" :headers="upheard" :auto-upload="true" :show-file-list="false" :on-progress="handelUpP" :on-success="handelUpS" :on-error="handelUpE">
                              <el-button size="small" @click="UpClick" type="primary">上传更新包</el-button>
                              <div slot="tip" class="el-upload__tip">请选择zip文件上传</div>
                          </el-upload>
                      </el-col>
                      <el-col :span="9">
                          <el-button size="small" @click="showwebbackinfo()" type="primary">查看备份</el-button>
                      </el-col>
                      <el-col :span="9">
                          <el-button size="small" @click="showwebstaticinfo()" type="primary">查看转储</el-button>
                      </el-col>
                  </el-row>
              </el-header>
              <el-main>
                  <div style="height:400px;width:100%;">
                      <div class="el-upload__tip" style="width:50%;float:left;">
                          <div v-for="(item, index) in uploadstatus" style="width:100%;" :key="index"><i v-if="item.c != 1" class="el-icon-error"></i><i v-else-if="item.s == 0" class="el-icon-loading"></i><i v-else class="el-icon-success"></i><span :style="{ 'color': item.c != 1 ? 'red' : 'black' }">{{ item.t }}</span> </div>
                      </div>
                      <div class="el-upload__tip" style="width:50%;float:left;">
                          <!-- <div style="height:40px;width:100%;text-align:center;">数据库版本:{{execver}}
                          </div> -->
                          <div style="height:400px;width:100%; overflow:auto;">
                              <pre>{{ execsql }}</pre>
                          </div>
                      </div>
                  </div>
              </el-main>
          </el-container>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" :visible.sync="dialogwebbackVisible" title="查看备份" class="logmodeldialog" :destroy-on-close="true">
          <el-container v-loading="backloading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
              <vxe-table ref="backvxtab" :data.sync="webbackTableData" :select-config="selectConfig" height="600px" highlight-current-row :loading="loadingwebback" highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" border fit header-align="center" size="mini" stripe width="100%">
                  <vxe-table-column field="name" title="文件名" width="160"></vxe-table-column>
                  <vxe-table-column field="lastwritetime" title="备份时间" width="160"></vxe-table-column>
                  <vxe-table-column field="length" title="文件大小" width="100"></vxe-table-column>
                  <vxe-table-column width="100">
                      <template v-slot="{ row }">
                          <el-button size="small" @click="restoreweb(row)" type="primary">恢复备份</el-button>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column width="100">
                      <template v-slot="{ row }">
                          <el-button size="small" @click="deleteweb(row)" type="primary">删除备份</el-button>
                      </template>
                  </vxe-table-column>
              </vxe-table>
          </el-container>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" :visible.sync="dialogwebstaticVisible" :title="cver" class="logmodeldialog" :destroy-on-close="true">
          <el-container v-loading="backloading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
              <vxe-grid height="600px" style="width:100%" :columns="webstaticTableColumn" :data="webstaticTableData" header-align="center" border highlight-current-row highlight-hover-row ref="staticvxtab" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" :loading="loadingwebstatic"></vxe-grid>
          </el-container>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" :visible.sync="dialogChgpwdVisible" title="修改密码" :destroy-on-close="true" width="400px" class="ms-content">
          <div>
              <el-header height="30px">
                  <div style="color:blue;text-align:center">当前用户: {{ username }}</div>
              </el-header>
              <el-main class="ms-content">
                  <el-form class="ms-content">
                      <el-form-item>
                          <el-row>
                              <el-col :span="5">
                                  <div class="grid-content">原&thinsp; 密&thinsp; 码</div>
                              </el-col>
                              <el-col :span="14">
                                  <div class="grid-content">
                                      <el-input :type="oldpwdflag == true ? 'password' : 'text'" v-model="pwdForm.opwd" ref="opwd" @keyup.enter.native="EnterAutoFocus('opwd')">
                                      </el-input>
                                  </div>
                              </el-col>
                              <el-col :span="5">
                                  <el-button icon="el-icon-view" style="float:none" @click="changeoType(1)"></el-button>
                              </el-col>
                          </el-row>
                      </el-form-item>
                      <el-form-item>
                          <el-row>
                              <el-col :span="5">
                                  <div class="grid-content">新&thinsp; 密&thinsp; 码</div>
                              </el-col>
                              <el-col :span="14">
                                  <div class="grid-content">
                                      <el-input :type="newpwdflag == true ? 'password' : 'text'" v-model="pwdForm.npwd" ref="npwd" @keyup.enter.native="EnterAutoFocus('npwd')" id="pwd">
                                      </el-input>
                                  </div>
                              </el-col>
                              <el-col :span="5">

                                  <el-button icon="el-icon-view" style="float:none;" @click="changeoType(2)"></el-button>

                              </el-col>
                          </el-row>
                      </el-form-item>
                      <el-form-item>
                          <el-row>
                              <el-col :span="5">
                                  <div class="grid-content">确认密码</div>
                              </el-col>
                              <el-col :span="14">
                                  <div class="grid-content">
                                      <el-input :type="againpwdflag == true ? 'password' : 'text'" v-model="pwdForm.anpwd" ref="anpwd" @keyup.enter.native="EnterAutoFocus('anpwd')">
                                      </el-input>
                                  </div>
                              </el-col>
                              <el-col :span="5">

                                  <el-button icon="el-icon-view" style="float:none;padding:0 0 0 10px" @click="changeoType(3)"></el-button>
                              </el-col>
                          </el-row>
                      </el-form-item>
                  </el-form>
              </el-main>
              <el-footer style="float:right" class="ms-content">
                  <el-button @click="isnullpwd()">确定</el-button>
                  <el-button @click="dialogChgpwdVisible = false">取消</el-button>
              </el-footer>
          </div>
      </el-dialog>
      <!--关于-->
      <el-dialog :visible.sync="dialogimgVisible" :show-close="false" class="aboutclass" width="600px">
          <div style="height:360px;width:100%">
              <el-image style="width: 100%; height: 360px" fits="fill" :src="imgurl"></el-image>
          </div>
          <div style="position:relative;top:-150px;left:300px;color:white;z-index:999;width:300px;">
              <table>
                  <tr>
                      <td align="right" style="color:yellow;width:80px;">版本：</td>
                      <td>{{ version }}</td>
                  </tr>
                  <tr>
                      <td align="right" style="color:yellow;">DB版本：</td>
                      <td>{{ hisversion }}</td>
                  </tr>
                  <tr v-if="dialogClientVersionVisible">
                      <td align="right" style="color:yellow;width:80px;">客户端：</td>
                      <td>{{ mainver }}</td>
                  </tr>
                  <tr v-if="dialogClientVersionVisible">
                      <td align="right" style="color:yellow;">eload：</td>
                      <td>{{ eloadver }}</td>
                  </tr>
                  <tr v-if="dialogClientVersionVisible">
                      <td align="right" style="color:yellow;">winexe：</td>
                      <td>{{ winexever }}</td>
                  </tr>
              </table>
          </div>
          <div style="position:relative;top:-70px;left:450px;color:white;z-index:999;width:300px;">
              {{ localTime }}
          </div>
      </el-dialog>
      <!--发送消息-->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" :visible.sync="dialogSendMsgVisible" :show-close="true" title="消息发布" width="1050px">
          <div style="height:620px">
              <rm-sendmsginfo key="sendmsginfo1" @closeSendMsg="dialogSendMsgVisible = false" :getDraft="true"></rm-sendmsginfo>
          </div>
      </el-dialog>
      <!--提醒中心-->
      <el-dialog v-el-drag-dialog :close-on-click-modal="false" :visible.sync="alertcenterVisible" :show-close="true" title="提醒中心" width="1050px">
          <div style="height:610px">
              <Tabs @closeAlertCenter="alertcenterVisible = false"></Tabs>
          </div>
      </el-dialog>
  </div>
</template>
<script>
import md5 from "js-md5";
import $ from "jquery";
import XEUtils from "xe-utils";
import RmSendmsginfo from "@/components/rmcompents/msgcenter/rm_sendmsginfo.vue";
export default {
  components: {
      RmSendmsginfo,
  },
  data() {
      return {
          currentMod: "LIS",
          dialogTableVisible: false,
          dialogUpgradeVisible: false,
          dialogChgpwdVisible: false,
          uploadurl: "",
          upheard: {},
          uploadstatus: [],
          bigmodels: [],
          collapse: true,
          topmenuCollapse: false,
          topdrop1showing: false,
          topdrop2showing: false,
          topmouseinmenu: false,
          fullscreen: 1,
          name: "ruimei",
          message: 0,
          logstring: "",
          loglength: 1,
          currentlogindex: 0,
          logfiles: [],
          sellogfile: "",
          loadingstatus: true,
          items: [], //菜单数组
          adminpm: false,
          WebVer: "",
          upgradestep: ["unzip", "delinvalid", "backupweb", "delbackup", "updb", "releaseweb"],
          txtupgradestep: ["正在解压更新包", "正在清理历史残留的无效更新文件", "正在备份网站", "正在删除超过30天的历史备份包", "正在升级数据库", "正在发布网站"],
          upgradesteperr: ["解压更新包超时，请检查更新包大小", "清理历史残留的无效更新文件失败，请检查服务器磁盘读写功能", "备份网站超时，请检查服务器磁盘读写是否异常或者原网站是否存在不必要的超大文件", "历史备份包删除失败，请检查服务器磁盘读写功能", "检查数据库升级脚本失败，请检查更新包", "发布网站失败，请检查服务器磁盘读写功能"],
          dialogsqlVisible: false,
          sqls: [],
          execver: "",
          execsql: "",
          dialogwebbackVisible: false,
          selectConfig: { tigger: "row" },
          webbackTableData: [],
          loadingwebback: false,
          dialogwebstaticVisible: false,
          loadingwebstatic: false,
          webstaticTableData: [],
          webstaticTableColumn: [],
          backloading: false,
          password: "",
          newpassword: "",
          againnewpassword: "",
          pwdForm: {
              opwd: "",
              npwd: "",
              anpwd: "",
          },
          oldpwdflag: true,
          newpwdflag: true,
          againpwdflag: true,
          imgurl: require("@/assets/img/about.jpg"),
          dialogimgVisible: false,
          dialogClientVersionVisible: false,
          mainver: "",
          eloadver: "",
          winexever: "",
          dialogSendMsgVisible: false,

          version: "1.0",
          hisversion: "1.0",
          sizeNum: 1.3,
          webbrowser: typeof jsObj != "undefined",
          localTime: "15:42:54",
          lis310multiple: "0",
          isbis: false,
          searchstr: "",
          selhisna: this.$tool.getLocalConfig("selectedhisna"),
          areaflag: false,
          searchplace: "输入血袋编号检索",
          alertcenterVisible: false,
          cver: "查看转储",
      };
  },
  created() {
    var that = this;
    this.isbis = this.$tool.checkBis();
    this.topmenuCollapse = this.$tool.getLocalConfig("topmenuCollapse") == "1";
    if (this.isbis) {
      this.collapse = this.$tool.getLocalConfig("collapse") == "1";
    }

    let pmv = localStorage.getItem("RMPageScale");
    if (pmv && pmv >= 1) {
      this.sizeNum = pmv;
    }
    this.uploadurl = this.$tool.baseUrl.replace(/api/, "z") + "upgradeweb";
    this.upheard = {
      rclclient: this.$tool.getSession(this.$tool.logintoken),
    };
    this.$bus.$on("menuClick", (msg, searchstr) => {
      // console.log(msg);
      that.items = msg;
      that.searchplace = searchstr;
      // console.log("menu", this.items);
      //Todo
    });
    this.$bus.$on("headermsgshake", (msg) => {
      console.log(msg);
      this.message = msg;
    });

    // this.$bus.$on("topmenuTempshowing", (msg) => {
    //     setTimeout(() => {
    //         document.onclick = function (ev) {
    //             // console.log("ev", ev);
    //             that.checkmouseout();
    //         };
    //     }, 1000);
    // });
    this.getadminpm();
    this.WebVer = this.$tool.getLocalConfig("webver");
    this.bigmodels = this.$tool.checkBis() ? this.$tool.getLocalConfig("bigbismodellist") : this.$tool.getLocalConfig("bigmodellist");
    this.currentMod = this.$tool.checkBis() ? this.$tool.getLocalConfig("bigbismodel") : this.$tool.getLocalConfig("bigmodel");
    this.selhisna = this.$tool.getLocalConfig("selectedhisna");
    this.$ddldata.IsAreaModeFun().then((res) => {
      this.areaflag = res;
    });
    //this.lis310multiple = this.$tool.getLocalConfig("lis310multiple");

    this.$bus.$on("focusSearchBox", (msg) => {
      if (this.$refs.searchBox) {
        this.$refs.searchBox.focus();
      }
    });
    this.auto_loginOption();
    this.fetchDataAndSetLocalConfig().then(() => {
      // 异步操作完成后设置计算属性的值
      this.currentMod =
        this.$tool.checkBis() ? this.$tool.getLocalConfig("bigbismodel") : this.$tool.getLocalConfig("bigmodel");
    });
  },
  computed: {
    currentModName() {
      // 从计算属性中删除副作用
      if (this.bigmodels && this.bigmodels.length > 0 && this.currentMod) {
        let cmod = this.bigmodels.find((m) => m.code == this.currentMod);
        if (cmod) return cmod.name;
      }
      if (this.bigmodels && this.bigmodels.length > 0) {
        return this.bigmodels[0].name;
      }
      if (this.$tool.checkBis()) {
        return "输血工作站";
      } else {
        return "检验工作站";
      }
    },
    downloadlogurl() {
      return this.$tool.baseUrl.replace(/api/, "z") + "logdownload?log=" + this.sellogfile;
    },
    username() {
      let username = this.$tool.getSession(this.$tool.loginusername);
      return username ? username : this.name;
    },
    userno() {
      let userno = this.$tool.getSession(this.$tool.loginuserno);
      return userno ? userno : this.userno;
    },
    hasUnreadMessages() {
      //如果有新消息，铃铛抖动一下
      console.log(this.message);
      return this.message > 0;
    },
  },
  methods: {
    fetchDataAndSetLocalConfig() {
      return this.$tool.request({
        url: "ucent/syspanel",
        method: "post",
        data: {
          action: "bigmodel",
        },
      }).then((res) => {
        if (this.$tool.checkBis()) {
          this.$tool.setLocalConfig("bigbismodellist", res.ms);
        } else {
          this.$tool.setLocalConfig("bigmodellist", res.ms);
        }
        this.bigmodels = res.ms;
      }).catch((e) => { });
    },
    drop1change(e) {
      this.topdrop1showing = e;
      this.checkmouseout();
    },
    drop2change(e) {
      this.topdrop2showing = e;
      this.checkmouseout();
    },
    headmouseleave() {
      this.topmouseinmenu = false;
      this.checkmouseout();
    },
    headmouseover() {
      this.topmouseinmenu = true;
    },
    checkmouseout() {
      var that = this;
      if (this.topmenuCollapse) {
        if (this.topdrop1showing || this.topdrop2showing || this.topmouseinmenu || this.dialogTableVisible || this.dialogUpgradeVisible || this.dialogwebbackVisible || this.dialogChgpwdVisible || this.dialogimgVisible) {
        } else {
          let haveshowing = false;
          $("div.el-menu--horizontal").each(function (index, eitem) {
            if (eitem.style.display != "none") {
              haveshowing = true;
              eitem.onmouseleave = function (e) {
                let temptimeout1 = setTimeout(() => {
                  that.$bus.$emit("topmenuMouseout", that.topmenuCollapse);
                  clearTimeout(temptimeout1);
                }, 500);
              };
            }
          });
          if (!haveshowing) this.$bus.$emit("topmenuMouseout", this.topmenuCollapse);
        }
      }
    },
    handleSwitchModel(command) {
      this.currentMod = command;
      if (this.$tool.checkBis()) {
        this.$tool.setLocalConfig("bigbismodel", command);
      } else {
        this.$tool.setLocalConfig("bigmodel", command);
      }

      this.$bus.$emit("switchmodel", this.currentMod);
      let temptimeout1 = setTimeout(() => {
        this.$bus.$emit("topmenuMouseout", true);
        clearTimeout(temptimeout1);
      }, 300);
    },
    adduploadstatus(c, t, s) {
      if (c == 0) {
        this.uploadstatus.push({ c: c, t: t, s: 1 });
      } else {
        if (!s) {
          s = 0;
        }
        this.uploadstatus.push({ c: c, t: t, s: s });
      }
      if (this.uploadstatus.length > 1) {
        this.uploadstatus[this.uploadstatus.length - 2].s = 1;
      }
    },
    UpClick() {
      this.uploadstatus = [];
      this.execver = "";
      this.execsql = "";
      this.adduploadstatus(1, "开始上传");
    },
    handelUpP(event, file, fileList) { },
    handelUpE(err, file, fileList) {
      console.log("err", err);
      this.adduploadstatus(0, "上传失败，请重试");
    },
    handelUpS(response, file, fileList) {
      if (response != "") {
        if (response == "当前用户不是管理员") {
          this.adduploadstatus(0, "当前用户不是管理员，禁止上传更新包", 1);
          return;
        }
        this.adduploadstatus(1, "上传完成");
        var upret = this.upgradeexec(600000, response, 0);
      } else {
        this.adduploadstatus(0, "获取上传文件失败，请检查升级包！");
      }
    },

    showwebbackinfo() {
      this.dialogwebbackVisible = true;
      this.loadingwebback = true;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          data: {
            action: "getwebback",
          },
        })
        .then((res) => {
          console.log("res", res);
          this.loadingwebback = false;
          if (res.errcode == "1") {
            this.webbackTableData = res.data;
          }
        })
        .catch((e) => {
          this.loadingwebback = false;
        });
    },
    showwebstaticinfo() {
      let that = this;
      this.dialogwebstaticVisible = true;
      this.loadingwebstatic = true;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          data: {
            action: "getwebstatic",
          },
        })
        .then((res) => {
          if (res.v) that.displaystaticinfoData(that, res);
          else this.loadingwebstatic = false;
        })
        .catch((e) => {
          this.loadingwebstatic = false;
        });
    },
    displaystaticinfoData(that, res) {
      // console.log("res", res);
      // that.tableColumn = res.Cols;

      that.cver = "查看转储-当前：" + res.v + "，生效版本：" + res.uv;
      that.webstaticTableColumn = res.data.Cols.map((item) => {
        let config = {
          title: item.title,
          width: item.width,
          slots: {
            default: ({ row, column }) => {
              // 渲染链接
              if (item.field && item.field == "id") {
                //生效状态可以转储
                //转储状态可以生效，删除
                //无效状态可以转储，删除
                switch (row["flag"]) {
                  case 1:
                    return [
                      <el-button
                        type="primary"
                        onclick={(evt) => {
                          that.StaticWebItem(evt, row, row[column.property]);
                        }}
                        plain
                      >
                        {" "}
                        转储{" "}
                      </el-button>,
                    ];
                  case 2:
                    return [
                      <el-button
                        type="danger"
                        onclick={(evt) => {
                          that.InUseWebItem(evt, row, row[column.property]);
                        }}
                        plain
                      >
                        {" "}
                        立即使用{" "}
                      </el-button>,
                      <el-button
                        type="warning"
                        icon="el-icon-delete"
                        onclick={(evt) => {
                          that.DelWebItem(evt, row, row[column.property]);
                        }}
                        plain
                      >
                        {" "}
                        删除{" "}
                      </el-button>,
                    ];
                  default:
                    return [
                      <el-button
                        type="primary"
                        onclick={(evt) => {
                          that.StaticWebItem(evt, row, row[column.property]);
                        }}
                        plain
                      >
                        {" "}
                        转储{" "}
                      </el-button>,
                      <el-button
                        type="warning"
                        icon="el-icon-delete"
                        onclick={(evt) => {
                          that.DelWebItem(evt, row, row[column.property]);
                        }}
                        plain
                      >
                        {" "}
                        删除{" "}
                      </el-button>,
                    ];
                }
              }

              if (item.field == "flag") {
                switch (row["flag"]) {
                  case 1:
                    return [<span style="color:green;">生效</span>];
                  case 2:
                    return [<span>转储</span>];
                  default:
                    return [<span style="color:#999999;">无效</span>];
                }
              }

              if (item.field == "fver") {
                if (row["fver"] == res.v && row["flag"] == "1") {
                  return [<span style="color:green;">{row[column.property]}</span>];
                } else if (row["fver"] == res.uv) {
                  return [<span style="color:red;">{row[column.property]}</span>];
                } else {
                  return [<span>{row[column.property]}</span>];
                }
              }

              // 渲染文本
              return [<span>{row[column.property]}</span>];
            },
          },
        };

        if (item.field && item.field == "id") {
          config.align = "center";
        }
        if (item.field) {
          config.field = item.field;
        }

        return config;
      });

      that.webstaticTableData = res.data.Data;
      that.loadingwebstatic = false;
    },
    DelWebItem(evt, row, uid) {
      let that = this;
      //console.log("uid", row, uid);
      that.$confirm("确实删除升级包：[" + row.fver + "] ?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          that.loadingwebstatic = true;
          this.$tool
            .request({
              url: "/ucent/upgrade",
              method: "post",
              data: {
                action: "OptWebUpdateItem",
                type: "del",
                id: row.id,
              },
            })
            .then((res) => {
              that.displaystaticinfoData(that, res);
            })
            .catch((e) => {
              this.loadingwebstatic = false;
            });
        })
        .catch(() => { });
    },
    StaticWebItem(evt, row, uid) {
      let that = this;
      that.loadingwebstatic = true;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          data: {
            action: "OptWebUpdateItem",
            type: "static",
            id: row.id,
          },
        })
        .then((res) => {
          that.displaystaticinfoData(that, res);
        })
        .catch((e) => {
          this.loadingwebstatic = false;
        });
    },
    InUseWebItem(evt, row, uid) {
      let that = this;
      //console.log("uid", row, uid);
      that.$confirm("确定将系统更改到：[" + row.fver + "] 这个版本?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          that.loadingwebstatic = true;
          this.$tool
            .request({
              url: "/ucent/upgrade",
              method: "post",
              data: {
                action: "OptWebUpdateItem",
                type: "inuse",
                id: row.id,
              },
            })
            .then((res) => {
              that.displaystaticinfoData(that, res);
            })
            .catch((e) => {
              this.loadingwebstatic = false;
            });
        })
        .catch(() => { });
    },
    restoreweb(row) {
      const h = this.$createElement;
      this.$confirm("", "提示", {
        message: h("p", null, [h("span", null, "是否要恢复 "), h("span", { style: "color: red" }, row.lastwritetime), h("span", null, "的备份，"), h("br", null, ""), h("span", null, "此操作将覆盖当前使用的网站，并即时生效, 是否继续?")]),
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        focusCancelButton: true,
        type: "warning",
      })
        .then(() => {
          this.restorewebexec(row);
        })
        .catch(() => { });
    },
    deleteweb(row) {
      const h = this.$createElement;
      this.$confirm("", "提示", {
        message: h("p", null, [h("span", null, "是否要删除 "), h("span", { style: "color: red" }, row.lastwritetime), h("span", null, "的备份，"), h("br", null, ""), h("span", null, "此操作将永久删除该文件, 是否继续?")]),
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        focusCancelButton: true,
        type: "warning",
      })
        .then(() => {
          this.deletewebexec(row);
        })
        .catch(() => { });
    },
    deletewebexec(row) {
      this.backloading = true;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          data: {
            action: "deleteback",
            filename: row.name,
          },
        })
        .then((res) => {
          let t = "成功";
          if (res.errcode == "1") {
          } else {
            t = "失败";
          }
          this.$alert(res.errmsg, t, {
            confirmButtonText: "确定",
            callback: (action) => {
              this.$refs.backvxtab.remove(row);
            },
          });
          this.backloading = false;
          return false;
        })
        .catch((e) => {
          console.log("error", e);
          this.$alert("删除备份时发生异常", "异常", {
            confirmButtonText: "确定",
          });
          this.backloading = false;
          return false;
        });
    },
    restorewebexec(row) {
      this.backloading = true;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          timeout: 600000,
          data: {
            action: "restoreweb",
            filename: row.name,
          },
        })
        .then((res) => {
          let t = "成功";
          if (res.errcode == "1") {
          } else {
            t = "失败";
          }
          this.$alert(res.errmsg, t, {
            confirmButtonText: "确定",
          });
          this.backloading = false;
          return false;
        })
        .catch((e) => {
          console.log("error", e);
          this.$alert("恢复备份时发生异常", "异常", {
            confirmButtonText: "确定",
          });
          this.backloading = false;
          return false;
        });
    },
    upgradeexec(timeo, filename, step) {
      let actionname = this.upgradestep[step];
      this.adduploadstatus(1, this.txtupgradestep[step]);
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          timeout: timeo,
          data: {
            action: actionname,
            filename: filename,
          },
        })
        .then((res) => {
          let len = this.uploadstatus.length;
          this.adduploadstatus(res.errcode, res.errmsg);

          if (res.errcode == "1" || res.errcode == "2") {
            step = step + 1;
            if (step >= this.upgradestep.length) {
              this.adduploadstatus(1, "恭喜您，本次升级成功结束！", 1);
              return true;
            }
            if (actionname == "updb") {
              let minVer = res.minVer;
              let maxVer = res.maxVer;
              if (maxVer > 0) {
                this.sqls = res.sqls;
                let upret = this.updbver(minVer, maxVer, timeo, filename, step);
              } else {
                this.upgradeexec(timeo, filename, step);
              }
            } else {
              this.upgradeexec(timeo, filename, step);
            }
          } else {
            this.adduploadstatus(0, "本次升级失败！", 1);
            return false;
          }
        })
        .catch((e) => {
          let lerr = this.upgradesteperr[step];
          this.adduploadstatus(0, lerr);
          this.adduploadstatus(0, "本次升级失败！", 1);
          return false;
        });
    },
    updbver(minVer, maxVer, timeo, filename, step) {
      let dbv = minVer;
      // this.dialogsqlVisible = true;
      this.execver = dbv;
      this.adduploadstatus(1, "开始执行数据库升级脚本，版本号：" + dbv);
      this.execsql = this.sqls[dbv].m_StringValue;
      this.$tool
        .request({
          url: "/ucent/upgrade",
          method: "post",
          timeout: timeo,
          data: {
            action: "updbver",
            filename: filename,
            cver: dbv,
          },
        })
        .then((res) => {
          this.adduploadstatus(res.errcode, res.errmsg);
          dbv = dbv + 1;
          if (res.errcode == "1") {
            if (dbv > maxVer) {
              //全部执行完成 return true;
              this.adduploadstatus(1, "数据库升级完成");
              this.execsql = "";
              this.updbview(filename, 0)
                .then(() => {
                  this.execsql = "";
                  this.upgradeexec(timeo, filename, step);
                })
                .catch(() => {
                  this.adduploadstatus(0, "本次升级失败！", 1);
                  return false; //脚本执行出错，返回false
                });
            } else {
              this.execver = this.execver + "     执行成功！";
              this.updbver(dbv, maxVer, timeo, filename, step);
            }
          } else {
            this.execver = this.execver + "     执行失败！";
            this.adduploadstatus(0, "数据库升级失败，本次更新失败", 1);
            //this.dialogsqlVisible = false;
            return false; //脚本执行出错，返回false
          }
        })
        .catch((e) => {
          this.adduploadstatus(0, "数据库升级脚本" + dbv + "执行超时，请咨询开发工程师");
          this.adduploadstatus(0, "数据库升级失败，本次更新失败", 1);
          // this.dialogsqlVisible = false;
          return false;
        });
    },
    updbview(filename, dbv) {
      return new Promise((s, f) => {
        if (dbv == 0) {
          this.adduploadstatus(1, "开始修复系统视图/存储过程");
        }
        this.$tool
          .request({
            url: "/ucent/upgrade",
            method: "post",
            timeout: 600000,
            data: {
              action: "updbview",
              filename: filename,
              dbv: dbv,
            },
          })
          .then((res) => {
            this.execsql = res.execsql;
            dbv = dbv + 1;
            if (res.errcode == "2") {
              this.adduploadstatus(1, "系统视图/存储过程修复完成");
              s();
            } else if (res.errcode == "1") {
              this.updbview(filename, dbv)
                .then(() => {
                  s();
                })
                .catch(() => {
                  f();
                });
            } else {
              this.adduploadstatus(0, "系统视图/存储过程修复 执行失败！" + res.errmsg);
              f();
            }
          })
          .catch((e) => {
            this.adduploadstatus(0, "系统视图/存储过程" + dbv + "执行超时，请咨询开发工程师");
            this.adduploadstatus(0, "系统视图/存储过程失败，本次更新失败");
            f();
          });
      });
    },
    getadminpm() {
      let loginutype = this.$tool.getSession(this.$tool.loginutype);
      if (!loginutype || loginutype == undefined || loginutype == null) {
        let temptimeout1 = setTimeout(() => {
          this.getadminpm();
          clearTimeout(temptimeout1);
        }, 500);
      } else {
        this.adminpm = loginutype === "G" || loginutype === "D";
      }

      // let buttonpermsStr = sessionStorage.getItem("buttonpremissions");
      // if (buttonpermsStr == undefined || buttonpermsStr == null) {
      //     setTimeout(() => {
      //         this.getadminpm();
      //     }, 500);
      // } else {
      //     let buttonperms = JSON.parse(buttonpermsStr);
      //     this.adminpm = buttonperms.find(m => m.name.indexOf("MNG") >= 0);
      // }
    },
    handleSelect(key, keyPath) {
      this.HandleCount(keyPath[1]);
      // console.log(key, keyPath);
    },
    MenuClick(item) {
      this.$tool.setSession("currentmenu", item.title);
      let path = item.index;
      if (this.lis310multiple > 0) {
        if (path.indexOf("LIS310") > -1 || path.indexOf("LIS311") > -1 || path.indexOf("LIS312") > -1 || path.indexOf("LIS313") > -1 || path.indexOf("LIS314") > -1) {
          path = this.$pub.getlis310path(this, path);
        }
      }
      if (path.indexOf("http") > -1) {
        if (typeof jsObj != "undefined") {
          if (path.indexOf("[currentuserno]") > -1) {
            path = path.replace("[currentuserno]", this.userno);
          }
          jsObj.ReadCard("runurl:" + path);
        } else {
          this.$alert("请使用" + this.$pub.clientname + "打开！", "提示");
        }
      } else {
        this.$router.push("/" + path);
      }
      //console.log("mm", item.title.substring(0, 6));
    },
    handlBMSelect: function (key, keyPath) {
      // console.log("key", key);
      // console.log("keypath", keyPath);
      this.currentMod = key;
      if (this.$tool.checkBis()) {
        this.$tool.setLocalConfig("bigbismodel", key);
      } else {
        this.$tool.setLocalConfig("bigmodel", key);
      }

      this.$bus.$emit("switchmodel", this.currentMod);
      this.dialogTableVisible = false;
    },
    LogOutRecord() {
      return new Promise((s, f) => {
        this.$tool
          .request({
            url: "ucent/login",
            method: "post",
            data: {
              action: "LogOutRecord",
              computername: this.$pub.getcpname(),
            },
          })
          .then((res) => {
            s(res);
          })
          .catch(f());
      });
    },
    loginout() {
      this.$tool.removeSession(this.$tool.loginuserno);
      this.$tool.removeSession(this.$tool.loginusername);
      this.$tool.removeSession(this.$tool.logintoken);
      this.$ddldata.msgparm.localReqChargedt = ""; //退出登录时清空申请单计价失败记住的不再提醒时间
      this.$tool.removeSession("noreg");
      sessionStorage.removeItem("buttonpremissions");
      this.$router.push("/login");
    },
    // 用户名下拉菜单选择事件
    handleCommand(command) {
      if (command == "loginout") {
        //退出登录增加登出日志
        this.LogOutRecord()
          .then(() => {
            this.loginout();
          })
          .catch((e) => {
            this.loginout();
          });
      } else if (command == "switchlanguage") {
        this.$i18n.locale = this.$i18n.locale === "zh" ? "en" : "zh";
        this.$tool.setLocalConfig("lng", this.$i18n.locale);
      } else if (command == "switchmodel") {
        // console.log("sw");
        this.bigmodels = this.$tool.checkBis() ? this.$tool.getLocalConfig("bigbismodellist") : this.$tool.getLocalConfig("bigmodellist");
        this.currentMod = this.$tool.checkBis() ? this.$tool.getLocalConfig("bigbismodel") : this.$tool.getLocalConfig("bigmodel");
        this.dialogTableVisible = true;
      } else if (command == "showlog") {
        this.$router.push("/showlog");
      } else if (command == "upgradeweb") {
        this.uploadstatus = [];
        this.sqls = [];
        this.execver = "";
        this.execsql = "";
        this.dialogUpgradeVisible = true;
      } else if (command == "clearcache") {
        // 弹出验证码对话框，后台收到验证码是正确的，才能开始清理
        let that = this;
        let ucode = "";
        let uscode = "";
        that.getSysPswData().then((clearcachepsw) => {
          console.log('clearcachepsw', clearcachepsw)
          if (clearcachepsw != "") {
            //存在弹密码窗
            let myComponent = () => import("../rmcompents/login/identifycachepwd.vue");
            that.$rmDialog(
              myComponent,
              {
                title: "请输入密码",
                confirmBtnText: "确定",
                cancelBtnText: "取消",
                width: "300px",
              },
              {}
            )
              .then((e) => {
                //console.log("sas", e.cachepsw);
                if (e.cachepsw.toUpperCase() == clearcachepsw.toUpperCase()) {
                  ucode = e.cachepsw.toUpperCase();
                  uscode = that.$tool.Encrypt(clearcachepsw.toUpperCase() + that.$tool.getSession(that.$tool.logintoken));
                  this.startclearcache(ucode, uscode);
                } else {
                  this.$alert("输入的缓存清理密码错误！", "提示").then(() => {
                    this.$ddldata.clearlocalcache();
                  });
                }
              })
              .catch((e) => { });
          } else {
            //不存在弹验证码
            let myComponent = () => import("../rmcompents/login/identifycommoninput.vue");
            that.$rmDialog(
              myComponent,
              {
                title: "请输入验证码",
                confirmBtnText: "确定",
                cancelBtnText: "取消",
                width: "300px",
              },
              {}
            )
              .then((e) => {
                console.log('eee', e)
                if (e.vcode == e.identifyCode) {
                  ucode = e.vcode;
                  uscode = that.$tool.Encrypt(e.identifyCode + that.$tool.getSession(that.$tool.logintoken));
                  this.startclearcache(ucode, uscode);
                } else {
                  this.$alert("验证码输入错误！", "提示").then(() => {
                    this.$ddldata.clearlocalcache();
                  });
                }
              })
              .catch(() => { });
          }
        });
      } else if (command == "isnullpwd") {
        this.pwdForm.opwd = "";
        this.pwdForm.npwd = "";
        this.pwdForm.anpwd = "";
        this.dialogChgpwdVisible = true;
        this.$nextTick(() => {
          this.$refs.opwd.focus();
        });
      } else if (command == "restartdec") {
        if (typeof jsObj != "undefined") {
          //重启解码
          jsObj.ReadCard("rmycmd:restartdec");
        }
      } else if (command == "about") {
        this.dialogimgVisible = true;
        this.$nextTick(async () => {
          try {
            const res = await this.$tool.request({
              url: "/ucent/upgrade",
              method: "post",
              data: {
                action: "QueryVersion",
              },
            });
            this.version = "7.0." + res.webVer;
            this.localTime = res.localTime;
            this.getData(res.localTime);
            this.hisversion = res.setVersion + "/" + res.curVersion + " " + res.dbname;
            try {
              if (typeof jsObj != "undefined" && jsObj.GetClientVersion) {
                this.dialogClientVersionVisible = true;
                let vobj = jsObj.GetClientVersion();
                this.mainver = vobj.m;
                this.eloadver = vobj.e;
                this.winexever = vobj.w;
              }
            } catch (e2) { }
          } catch (e) { }
        });
      } else if (command == "upgradeLog") {
        this.$router.push("/upgradelog");
      } else if (command == "sendmsg") {
        this.dialogSendMsgVisible = true;
      } else if (command == "calc") {
        if (typeof jsObj != "undefined") {
          var opencalc = "runexe:C:/Windows/System32/calc.exe";
          jsObj.ReadCard(opencalc);
        } else {
          this.$alert("请使用" + this.$pub.clientname + "打开系统", "错误", {
            confirmButtonText: "确定",
          });
        }
      } else if (command == "notepad") {
        if (typeof jsObj != "undefined") {
          var opennotepad = "runexe:C:/Windows/System32/notepad.exe";
          jsObj.ReadCard(opennotepad);
        } else {
          this.$alert("请使用" + this.$pub.clientname + "打开系统", "错误", {
            confirmButtonText: "确定",
          });
        }
      }
    },
    //公共方法
    startclearcache(ucode, uscode) {
      this.$tool
        .request({
          url: "/ucent/login",
          method: "post",
          data: {
            action: "clearcache",
            ucode: ucode, //e.vcode,
            uscode: uscode, //that.$tool.Encrypt(e.identifyCode + that.$tool.getSession(that.$tool.logintoken)),
          },
        })
        .then((res) => {
          if (res.flag == -1) {
            this.$alert("清除失败！<br/>" + res.msg, "错误", {
              dangerouslyUseHTMLString: true,
            }).then(() => {
              //location.reload();
              this.$ddldata.clearlocalcache();
            });
          } else {
            //console.log(res);
            this.$alert(res.msg, "提示").then(() => {
              //location.reload();
              this.$ddldata.clearlocalcache();
            });
          }
        });
    },
    //获取系统中是否存在系统缓存密码配置
    getSysPswData() {
      return new Promise((s, f) => {
        this.$tool
          .request({
            url: "/ucent/login",
            method: "post",
            data: {
              action: "getSysPswData",
            },
          })
          .then((res) => {
            console.log(res.data);
            s(res.data);
          })
          .catch((e) => {
            f("");
          });
      });
    },
    getData(time) {
      var date = new Date(time);
      date.setSeconds(date.getSeconds() + 1);
      let _this = this;
      let temptimeout1 = setTimeout(() => {
        _this.localTime = XEUtils.toDateString(date, "yyyy-MM-dd HH:mm:ss");
        _this.getData(_this.localTime);
        clearTimeout(temptimeout1);
      }, 1000);
    },
    // 侧边栏折叠
    collapseChage() {
      this.collapse = !this.collapse;
      if (this.isbis) {
        this.$tool.setLocalConfig("collapse", this.collapse ? "1" : "0");
      }

      this.$bus.$emit("collapse", this.collapse);
    },
    // 全屏事件
    handleFullScreen() {
      if (typeof jsObj != "undefined") {
        if (this.fullscreen == 0) {
          this.$pub.SetWindowStyle(false, false, false);
          this.fullscreen = 1;
        } else if (this.fullscreen == 1) {
          this.$pub.SetWindowStyle(false, false, true);
          this.fullscreen = 2;
        } else if (this.fullscreen == 2) {
          this.$pub.SetWindowStyle(true, true, false);
          this.fullscreen = 0;
        }
      } else {
        let element = document.documentElement;
        if (this.fullscreen == 2) {
          if (document.exitFullscreen) {
            document.exitFullscreen();
          } else if (document.webkitCancelFullScreen) {
            document.webkitCancelFullScreen();
          } else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
          } else if (document.msExitFullscreen) {
            document.msExitFullscreen();
          }
          this.fullscreen = 1;
        } else {
          if (element.requestFullscreen) {
            element.requestFullscreen();
          } else if (element.webkitRequestFullScreen) {
            element.webkitRequestFullScreen();
          } else if (element.mozRequestFullScreen) {
            element.mozRequestFullScreen();
          } else if (element.msRequestFullscreen) {
            // IE11
            element.msRequestFullscreen();
          }
          this.fullscreen = 2;
        }
      }
    },
    reload() {
      location.reload();
    },
    toggleTopmenu() {
      this.topmenuCollapse = !this.topmenuCollapse;
      this.$tool.setLocalConfig("topmenuCollapse", this.topmenuCollapse ? "1" : "0");
      this.$bus.$emit("topmenuCollapse", this.topmenuCollapse);
    },
    closewindow() {
      if (typeof jsObj != "undefined") {
        //jsObj.CloseWindow();
        this.LogOutRecord()
          .then(() => {
            jsObj.CloseWindow();
          })
          .catch((e) => {
            jsObj.CloseWindow();
          });
      }
    },
    setwindowmin() {
      if (typeof jsObj != "undefined") {
        jsObj.SetWindowMin();
      } else {
        this.$alert("请使用" + this.$pub.clientname + "打开系统", "错误", {
          confirmButtonText: "确定",
        });
      }
    },
    changeoType(flag) {
      if (flag == 1) {
        this.oldpwdflag = !this.oldpwdflag;
      } else if (flag == 2) {
        this.newpwdflag = !this.newpwdflag;
      } else if (flag == 3) {
        this.againpwdflag = !this.againpwdflag;
      }
    },
    isnullpwd() {
      if (this.pwdForm.npwd == "" && this.pwdForm.anpwd == "") {
        this.$confirm("您确定不设置密码吗？", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.changePwd();
          })
          .catch(() => { });
      } else {
        this.changePwd();
      }
    },
    //修改密码
    async changePwd() {
      // var v = this.pwdForm.npwd;
      // let reg = /^(?=.*[a-zA-Z])(?=.*[1-9])(?=.*[\W]).{6,}$/;
      // if ((reg = false)) {
      //     this.$message({
      //         message: "密码必须含有大写字母,小写字母,和特殊符号，并不得短于6个字符。",
      //         type: "warning"
      //     });
      //     return false;
      // }
      // console.log("CC", reg.test(v));
      // alert(reg.test(v));
      let flag = true;
      try {
        const res = await this.$tool.request({
          url: "/ucent/login",
          method: "post",
          data: {
            action: "verifyPwdRule",
            userno: this.userno,
            password: this.pwdForm.npwd,
          },
        });
        if (res.flag == 99) {
          flag = false;
          this.$alert(res.msg, "提示", {
            confirmButtonText: "确定",
            type: "error",
          });
          return false;
        } else {
          flag = true;
        }
      } catch (e) { }
      if (!flag) {
        return false;
      }
      var pwd = md5("rms-" + this.pwdForm.opwd + "-rme");
      var npwd = md5("rms-" + this.pwdForm.npwd + "-rme");
      var agnpwd = md5("rms-" + this.pwdForm.anpwd + "-rme");
      if (npwd == agnpwd) {
        this.$tool
          .request({
            url: "/ucent/login",
            method: "post",
            data: {
              action: "chgpwd",
              userno: this.userno,
              password: pwd,
              newpassword: npwd,
            },
          })
          .then((res) => {
            console.log(res);
            if (res.errcode == "1") {
              this.$message({
                message: "保存成功！",
                type: "success",
              });
            } else {
              this.$message.error(res.errmsg);
            }
            this.dialogChgpwdVisible = false;
          });
      } else {
        this.$message.error("两次密码输入不一致，请重新填写！");
        return false;
      }
    },
    EnterAutoFocus(element) {
      if (element == "opwd") {
        this.$refs.npwd.focus();
      } else if (element == "npwd") {
        this.$refs.anpwd.focus();
      } else if (element == "anpwd") {
        this.isnullpwd();
      }
    },
    HandleCount(keycode) {
      this.$tool.request({
        url: "/ucent/dashboard",
        method: "post",
        data: {
          action: "addcounts",
          prgcode: keycode,
        },
      });
    },
    handleSizeChange(value) {
      console.log(this.sizeNum);
      //先兼容现在的，等将来和壳配合好了之后再使用
      if (typeof jsObj != "undefined") {
        this.$pub.SetScale(this.sizeNum);
      } else {
        document.body.style.zoom = value;
      }
      //this.$pub.SetScale(this.sizeNum);
      localStorage.setItem("RMPageScale", this.sizeNum);
      // console.log(this.sizeNum);
      // this.sizeNum = value;
    },
    searchbis() {
      var that = this;
      if (that.searchstr == "" || that.searchstr == null) {
        return;
      }
      //查找
      this.$tool
        .request({
          url: "/ucent/syspanel",
          method: "post",
          data: {
            action: "getnotype",
            searchstr: that.searchstr,
          },
        })
        .then((res) => {
          if (res.errcode == "0") {
            if (res.flag == 8) {
              this.$router.push("/" + res.prgcode);
            } else {
              that.$bus.$emit("searchBIS", that.searchstr, "", res.flag);
            }
          } else {
            that.$alert(res.errmsg, "提示");
          }
          that.searchstr = "";
        })
        .catch((e) => { });
    },
    auto_loginOption() {
      this.$tool
        .request({
          url: "/ucent/login",
          method: "post",
          data: {
            action: "auto_loginOption",
            macaddress: this.macaddress,
            sqlkey: "LIS",
          },
        })
        .then((res) => {
          this.lis310multiple = res.lis310multiple;

          //console.log("as", this.msgtypeOption);
          this.$tool.setLocalConfig("lis310multiple", res.lis310multiple);
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    openalertcenter() {
      this.alertcenterVisible = true;
    },
  },
  mounted() {
    // if (document.body.clientWidth < 1500) {
    //     this.collapseChage();
    // }
  },
  beforeDestroy() {
    this.$bus.$off("menuClick");
    this.$bus.$off("focusSearchBox");
    this.$bus.$off("headermsgshake");
  },
};
</script>
<style scoped>
@media only screen and (min-width: 1024px) {
  ::v-deep  .el-submenu__title {
      padding: 0 15px !important;
  }
}

.selectpeople {
  position: absolute;
  top: 30px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.tree {
  overflow-y: auto;
  overflow-x: scroll;
  height: 100%;
  border: 1px solid #ccc;
}

.el-button {
  float: left;
}

.el-main {
  overflow: hidden;
}

.header {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 35px;
  font-size: 16px;
  color: #fff;
  z-index: 20;
  overflow-y: hidden;
  background-color: #0095d9;
}

.collapse-btn {
  float: left;
  padding: 0 5px;
  cursor: pointer;
  line-height: 35px;
  width: 40px;
  text-align: center;
}

.collapse-btn,
.header .logo-fold {
  background-color: #1476a5;
}

.collapse-btn:hover {
  background-color: #2876c3;
}

.header .logo,
.header .logo-fold {
  float: left;
  line-height: 35px;
  font-size: 15px;
  text-align: center;
  min-width: 100px;
  /* margin-top: 1px; */
}

.header .logo {
  background-color: #1476a5;
}

.header-right {
  float: right;
  padding-right: 20px;
}

.header-user-con {
  display: flex;
  height: 35px;
  align-items: center;
}

.btn-fullscreen {
  transform: rotate(45deg);
  margin-top: 2px;
  font-size: 20px;
  height: 30px !important;
}

.btn-bell,
.btn-homepage,
.btn-fullscreen {
  position: relative;
  width: 26px;
  height: 35px;
  text-align: center;
  border-radius: 15px;
  cursor: pointer;
  padding-top: 3px;
}

.btn-homepage {
  line-height: 30px;
}

.btn-bell {
  line-height: 30px;
}

.btn-bell-badge {
  position: absolute;
  right: 0;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #f56c6c;
  color: #fff;
}

.btn-bell .el-icon-bell {
  color: #fff;
}

.btn-homepage .el-icon-s-home {
  color: #fff;
}

.btn-homepage .el-icon-refresh {
  color: #fff;
}

.btn-close,
.tool-btn {
  width: 30px;
  text-align: center;
  margin-left: 20px;
  cursor: pointer;
}

.user-name {
  margin-left: 40px;
}

/* .switchmodel {
} */

.user-avator {
  margin-left: 20px;
}

.user-avator img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.el-dropdown-link {
  color: #fff;
  cursor: pointer;
}

.el-dropdown-menu__item {
  text-align: center;
}

.chgpwd {
  width: 800px;
  height: 500px;
  text-align: center;
}

.grid-content {
  font-size: 16px;
  color: #000;
}

.ms-content {
  padding: 0px 0px 0px 0px;
}

::v-deep .el-menu--horizontal > .el-menu-item {
  height: 35px !important;
  line-height: 35px !important;
}

::v-deep .el-submenu__title span {
  color: #fff;
}

::v-deep .el-submenu__title i {
  color: #fff;
}

::v-deep .el-submenu {
  background-color: transparent !important;
}

::v-deep .el-menu-item {
  background-color: white !important;
}

::v-deep .el-menu-item span {
  color: #fff;
}

::v-deep .el-menu-item i {
  color: #fff;
}

::v-deep .el-submenu__title:hover {
  background-color: #00a9f4 !important;
}

::v-deep .el-menu {
  background-color: transparent !important;
}

::v-deep .modeactive {
  color: #f56c6c !important;
}

::v-deep .switchmodeldialog .el-dialog {
  width: 200px;
}

::v-deep .switchmodeldialog .el-dialog .el-menu {
  border: none;
  text-align: center;
}

::v-deep  .el-submenu__title,
.el-menu-item {
  padding: 0 8px;
}

::v-deep  .el-submenu__title,
.el-menu-item {
  height: 35px !important;
  line-height: 35px !important;
}

::v-deep  .myclass .el-dialog__body {
  padding: 0;
  height: 396px;
  overflow: hidden;
}

::v-deep  .myclass .el-dialog__header {
  padding: 0;
}

::v-deep  .aboutclass .el-dialog__body {
  padding: 0;
  height: 360px;
  overflow: hidden;
}

::v-deep  .aboutclass .el-dialog__header {
  padding: 0;
}

::v-deep  .sendmsgdial .el-dialog__body {
  padding: 0;
  height: 450px;
}

.el-menu.el-menu--horizontal {
  border-bottom: 0;
}

.logodropdown {
  background-color: #1476a5;
  border: 0 !important;
}

.logodropdown li {
  font-size: 14px;
  color: #fff;
  border-bottom: 0;
  height: 42px;
  line-height: 42px;
}

.logodropdown li:hover {
  color: #fff;
  background-color: #1681b4;
}

.rmbistopmenuitem {
  background-color: #f4f4f4 !important;
  display: block;
  line-height: 40px;
  padding: 0 10px;
}

.rmbistopmenuitem:hover {
  background-color: #ffffff !important;
}

.rmbistopline {
  border-top: solid 1px #bbb;
}

::v-deep .bismenu .el-submenu__title i {
  display: none;
}

::v-deep .bissearch .el-input__inner {
  border-radius: 6px;
}

.shake-element {
  position: relative;
}

@keyframes shake {
  0% {
      transform: rotateZ(0deg);
  }

  20% {
      transform: rotateZ(-10deg);
  }

  40% {
      transform: rotateZ(10deg);
  }

  60% {
      transform: rotateZ(-10deg);
  }

  80% {
      transform: rotateZ(10deg);
  }

  100% {
      transform: rotateZ(0deg);
  }
}

.shake {
  animation: shake 0.8s infinite;
}
</style>
